package com.ichart.doc;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Event {
	private String method;
	private String annotation;
	private String definedBy;
	private String fullName;
	List<Item> paramters = new ArrayList<Item>();
	public static Pattern ONEROW = Pattern.compile("^\\s*(.*?)\\s*$",Pattern.MULTILINE);
	public static Pattern ITEM = Pattern.compile("^@paramter\\s*(.*?)#(\\w*)(.*?)$",Pattern.MULTILINE);
	public static Pattern EVENT = Pattern.compile("@event(.*?)@paramter",Pattern.DOTALL);
	
	
	public Event(String desc,String method,String definedBy, String fullName) {
		Matcher row = EVENT.matcher(desc);
		while(row.find()){
			this.setAnnotation(row.group(1).trim());
		}
		Matcher param = ITEM.matcher(desc);
		while(param.find()){
			paramters.add(new Item(param.group(2),param.group(1),param.group(3)));
		}
		this.method = method;
		this.definedBy = definedBy;
		this.fullName = fullName;
	}
	
	

	public void put(String attribute, String type, String annotation){
		paramters.add(new Item(attribute,type,annotation));
	}
	
	public String getMethod() {
		return method;
	}



	public void setMethod(String method) {
		this.method = method;
	}



	public String getAnnotation() {
		return annotation;
	}
	public void setAnnotation(String annotation) {
		this.annotation = annotation;
	}
	public String getDefinedBy() {
		return definedBy;
	}
	public void setDefinedBy(String definedBy) {
		this.definedBy = definedBy;
	}
	public String getFullName() {
		return fullName;
	}
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}
	public List<Item> getParamters() {
		return paramters;
	}
	public void setParamters(List<Item> paramters) {
		this.paramters = paramters;
	}
	

	
	
	
}
